<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>10_rest参数.html</title>
</head>

<body>

    <script>
        //ES6引入rest参数，用于获取函数的实参，用来代替arguments
        //ES5 获取实参的方式
        function data() {
            console.log(arguments);
        }
        data('年', '萨尼', '阿是');

        //rest 参数
        function haha(...args) {
            console.log(args); //可以调用数组的方法:filter some map every
        }
        haha('s发热', '我和牛', '回味');//返回数组

        //rest 参数必须要放到参数最后
        function fn(a, b, ...args) {
            console.log('a=', a);
            console.log('b=', b);
            console.log('args=', args);
        }
        fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);




    </script>


</body>

</html>